package com.sctvcloud.renhe.ui.adapter.holder;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.sctvcloud.renhe.R;
import com.sctvcloud.renhe.beans.Branch;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/7/4 0004.
 */

public class DepartHolder extends BaseBranchHolder {

    @BindView(R.id.tv_name)
    public TextView tv_name;
    @BindView(R.id.iv_arrow)
    public ImageView iv_arrow;
    @BindView(R.id.re_top)
    public RelativeLayout re_top;

    private Branch fRebellion;


    private RequestListener<String, GlideDrawable> lis = new RequestListener<String, GlideDrawable>() {
        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            return false;
        }

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            return false;
        }
    };


    public DepartHolder(final Context context, View itemView) {
        super(context, itemView);

//        itemView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent(context, ApplyDetailActivity.class);
//                intent.putExtra(EX_DATA, fRebellion);
//                intent.putExtra(EX_COMMENT_TYPE, 4);
//                intent.putExtra(DO_UP_POS, getAdapterPosition());
//                context.startActivity(intent);
//
//            }
//        });

    }

    @Override
    public void onDestory() {
        super.onDestory();
    }

    @Override
    protected void initInject() {
        ButterKnife.bind(this, itemView);
    }


    @Override
    public void setData(Branch fRebellion) {
        this.fRebellion = fRebellion;
        super.setData(fRebellion);

        tv_name.setText(fRebellion.getBranchName());
        if(fRebellion.isChoose() ){
            iv_arrow.setVisibility(View.VISIBLE);
        }else{
            iv_arrow.setVisibility(View.INVISIBLE);
        }

    }

    @OnClick({R.id.re_top})
    public void itemClick(View view) {
        switch (view.getId()) {
            case R.id.re_top:
                if (internalClick != null) {
                    internalClick.onItemInternalClick(itemView, view, getAdapterPosition());
                }
                re_top.setVisibility(View.VISIBLE);
                break;

        }
    }

}
